<?php
namespace Home\Controller;
use Common\Controller\CommonController;

class OrderController extends CommonController {
	
	
	
	function index(){
		$res=array();
		if($_POST){
			$arr=$_POST;
			$where=array(
				"paystate"=>$arr['paystate'],
			);
			
			$count=M('order')->where($where)->count();
			$order=M("order")->where($where)->select();
			foreach ($order as $value) {
				$value['time']=date('Y-m-d H:i:s',$value['time']);
				$li=M('order_msg')->where(array('out_trade_no'=>$value['order']))->find();
				$value['trade_no']=$li['trade_no'];
				$value['paytime']=$li['notify_time'];
				$res[]=$value;
			}
		
		}else{
			
			$count=M('order')->count();
			$order=M("order")->select();
			
			
			foreach ($order as $key=>$value)  {
				
				$li=M('order_msg')->where(array('out_trade_no'=>$value['order']))->find();
				$value['trade_no']=$li['trade_no'];
				$value['paytime']=$li['notify_time'];
				$value['time']=date('Y-m-d H:i:s',$value['time']);
			
				$res[]=$value;
			};
			
			
		
		}
		$page=new \Think\Pager($count,10);
		$show=$page->showhtml();// 分页显示输出		
		$this->assign('list',$res);
		$this->assign('page',$show);
		$this->display('index');
	}
	function up(){
		$data=array(
			'id'=>$_POST['id'],
			'gostatus'=>1,
		);
		$res=M("order")->save($data);
		$this->redirect("Order/index");
	}

	
}